<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2022/10/2
  Time: 11:32
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<script src="js/jquery-1.8.3.js"></script>
<html>
<head>
    <title>新能源汽车动力电池信息</title>
  <style>
    #box{
      width: 1000px;
      margin: 0 auto;
    }
    h1{
      text-align: center;
    }
    #table tr td{
      text-align: center;
      width: 120px;
      height: 30px;
    }
  </style>
</head>
<body>
<div id="box">
    <h1>新能源汽车动力电池信息</h1>
  <table id="table" border="1px solid black">
    <tr>
      <td>编号</td>
      <td>车型</td>
      <td>所属城市</td>
      <td>使用单位</td>
      <td>压差报警值</td>
      <td>报警时间</td>
      <td>操作</td>
    </tr>
    <c:forEach items="${list}" var="list">
      <tr>
        <td><a href="update?id=${list.id}">${list.id}</a></td>
        <td>${list.carName}</td>
        <td>${list.cityName}</td>
        <td>${list.userName}</td>
        <td>${list.pressureValue}</td>
        <td>${list.time}</td>
        <td><a href="#" onclick="dele(${list.id})">删除</a></td>
      </tr>
    </c:forEach>
  </table>
</div>
</body>
<script>
  $(function (){
    $("#table tr:odd").css("background","#f0fff9")
    $("#table tr:even").css("background","#f0faff")
  })
  function dele(id){
    if (confirm("确定要删除吗?")) {
      $.post(
              "delete", {"id": id}, function (data) {
                if (data == "true") {
                  alert("删除成功")
                  location.href = "list"
                } else {
                  alert("删除失败")
                }
              }
      )
    }
  }
</script>
</html>
